package com.wms.controller;

import com.wms.bean.ResultBean;
import com.wms.core.R;
import com.wms.entity.Province;
import com.wms.service.AreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "省、市、区三级联查（废弃）")
public class AreaController {
    @Autowired
    AreaService areaService;

    // 获取全国所有省份（用于初始化级联选择器）
    @ApiOperation("获取全国所有省份")
    @GetMapping("/api/areas/provinces")
    public ResultBean getAllProvinces() {
        List list=areaService.getAllProvinces();
        return R.success("获取全国所有省份",list);
    }

    // 根据省份ID获取三级结构（可选，用于精准查询）
    @ApiOperation("根据省份ID获取三级结构")
    @GetMapping("/api/areas/province/{id}")
    public ResultBean getProvinceDetail(@PathVariable Integer id) {
        Province province=areaService.getProvinceWithChildren(id);
        return R.success("获取全国所有省份",province);
    }
}

